<?php
	session_start();
	include('../functions/soap.php');
	include('../subpages/head.php');
	
	// -- Initiate testing -- //
	echo('<h1>Testcase: [baseclass]Stage</h1>');
	
	//Create Stage
	$testStage = new Stage($wsdl);
	
			//Create Student1
			$newStudent1 = new Student($wsdl);
			$newStudent1->setData('1111111', 'Harry1', 'Verwoerd1', 'der', 'Informatica');
			$student1 = $newStudent1->CreateStudent();
			echo('Student1 created: '.$student1.'<br />');
			//Create Student2
			$newStudent2 = new Student($wsdl);
			$newStudent2->setData('2222222', 'Harry2', 'Verwoerd2', 'der', 'Informatica');
			$student2 = $newStudent2->CreateStudent();
			echo('Student2 created: '.$student2.'<br />');
			//Create Docent
			$newDocent = new Docent($wsdl);
			$newDocent->setData('1111111', 'Henk', 'Visserz', 'van der', 'Docent I', '0612345678', 'Informatica');
			$docent = $newDocent->createDocent();
			echo('Docent created: '.$docent.'<br />');
				//Create Bedrijf
					$testBedrijf = new Bedrijf($wsdl);
					$testBedrijf->setData('test_Bedrijfsnaam', 'test_Straatnaam', '10', 'b', 'test_Plaatsnaam', '1234 AA',
										  'http://www.testwebsite.com', 'test@mail.com', '0123456789', 
										  '-Test- Dit bedrijf is automatisch aangemaakt.');
					$bedrijfsid = $testBedrijf->save();
					echo('Bedrijf created: '.$bedrijfsid.'<br />');
			//Create Contact
			$newContact = new Contact($wsdl);
			$newContact->setData('John', 'Koffie', 'den', 'Systeembeheerder', 'koffie@tbn.com', '0612345678', 
								 'Bereikbaar op maandag, dinsdag, woensdag.', $bedrijfsid, true, false);
			$contact = $newContact->save();
			echo('Contact created: '.$contact.'<br />');
	//Fill array with testdata
	$setstage = array();
	$setstage[] = '01/02/2008'; //van
	$setstage[] = '18/06/2008'; //tot
	$setstage[] = $student1; //student1
	$setstage[] = $student2; //student2
	$setstage[] = $docent; //docent
	$setstage[] = $contact; //bedrijfsbegeleider
	$setstage[] = 'Stage'; //type
	$setstage[] = 1; //status

	//Set data with set-methods
	$testStage->setId(NULL);
	$testStage->setVan($setstage[0]);
	$testStage->setTot($setstage[1]);
	$testStage->setStudent1($setstage[2]);
	$testStage->setStudent2($setstage[3]);
	$testStage->setDocent($setstage[4]);
	$testStage->setBedrijfsbegeleider($setstage[5]);
	$testStage->setType($setstage[6]);
	$testStage->setStatus($setstage[7]);

	//print array
	echo('<strong>Ingevoerde waarden in SETTERS: </strong>');
	echo('<pre>');
	print_r($setstage);
	echo('</pre>');
	
	//Save object to database
	$new_id = $testStage->save();
	echo('<strong>save() methode aangeroepen...</strong><br />');
	echo('Return value: '.$new_id.'<br /><br />');
	
	//Get saved bedrijf object from database
	$testGetStage = new GetStage($wsdl);
	$stageObj = $testGetStage->getStage($new_id);
	
	//Get Object data with get-methods
	$getstageobj = array();
	$getstageobj[] = $stageObj->getVan();
	$getstageobj[] = $stageObj->getTot();
	$getstageobj[] = $stageObj->getStudent1();
	$getstageobj[] = $stageObj->getStudent2();
	$getstageobj[] = $stageObj->getDocent();
	$getstageobj[] = $stageObj->getBedrijfsbegeleider();
	$getstageobj[] = $stageObj->getType();
	$getstageobj[] = $stageObj->getStatus();
	
	//Print array
	echo('<strong>Waarden gehaald uit gesavede object: </strong>');
	echo('<pre>');
	print_r($getstageobj);
	echo('</pre>');
	
	//Compare arrays
	echo('<strong>Vergelijk input met output...</strong><br />');
	$c = count($getstageobj);
	for($i = 0; $i < $c; $i++){
		if($getstageobj[$i] != $setstage[$i]){
			echo('<span style="color:red; font-weight:bold;">Fout! Uitvoer &raquo;<i>'.$getstageobj[$i].'</i>&laquo; 
					komt niet overeen met invoer &raquo;<i>'.$setstage[$i].'</i>&laquo;</span><br />');
		}
		else{
			echo('<span style="color:green;">Goed!</span> Uitvoer &raquo;<i>'.$getstageobj[$i].'</i>&laquo; 
					komt overeen met invoer &raquo;<i>'.$setstage[$i].'</i>&laquo;<br />');
		}
	}
	
?>